package com.ww.springboot.boot.javabase.list;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 描述：不可修改的list
 *
 * @author wanwei
 * @since 2021-07-08 15:38
 */
public class UnmodifiableListDemo1 {

    public static void main(String[] args) {

        List<String> list = new ArrayList<>();
        list.add("1");

        List<String> list2 = Collections.unmodifiableList(list);

        System.out.println(list2.get(0));
        list2.add("2");
        System.out.println(list2.toString());
    }
}
